package it.txt.access.capability.finder.util;

import it.txt.access.capability.commons.filter.FilterCommons;

import java.io.File;
import java.io.FilenameFilter;

/**
 * @author seccia
 * @author Salvatore Piccione (TXT e-solutions SpA - salvatore.piccione AT network.txtgroup.com)
 */
public class CapabilityFileNameFilter implements FilenameFilter {

    private static final String EXTENSION = "xml";
    
    public boolean accept(File dir, String name) {
        File file = new File(dir, name);
        if (file.isDirectory()) {
            return false;
        }

        String extension = FilterCommons.getFileExtension(file);
        if (extension != null) {
            if (extension.equals(EXTENSION)) {
                return true;
            } else {
                return false;
            }
        } else
            return false;
    }
}
